package com.example.daiyinuo.leetcode;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Callable<I extends Number> {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //MyThread1 myThread1 = new MyThread1();
        FutureTask<Integer> futureTask = new FutureTask(new MyThread1());
        new Thread(futureTask).start();//开启线程
        System.out.println(futureTask.get());//获取返回值
    }
}

class MyThread1 extends Callable<Integer> implements java.util.concurrent.Callable {
    public Integer call(){
        int count = 0;
        for(int i=0;i<=100;i++){

                count+=i;

        }
        return count;
    }
}
